﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using portfolio.Common;
using portfolio.Computation;
using Microsoft.FSharp.Core;

namespace portfolio.Business
{
    public class PhysicsBL
    {
        public string ParseXYZ(int? x, int? y, int? z)
        {
            string returnString = "";
            var X = ParserParams.Value(x);
            var Y = ParserParams.Value(y);
            var Z = ParserParams.Value(z);
            
            ParseXYZ parser = new ParseXYZ(X,Y,Z);
            Tuple<string, int> result = parser.result;

            if (result.Item1.ToString().ToLower().Contains("Error:".ToLower()))
            {
                returnString = result.Item1.ToString();
            }
            else
            {
                returnString = result.Item1.ToString() + result.Item2.ToString();
            }

            return returnString;
        }
    }

    class ParserParams
    {
        public static FSharpOption<int> Value(int? value)
        {
            if (value != null)
            {
                return new FSharpOption<int>(value.Value);
            }
            else
            {
                return FSharpOption<int>.None;
            }
        }
    }
}
